# other methods that could be supported include
# "AVERAGE_MAGPHASE", "RMS", "BILINEAR", "CUBIC", "CUBICSPLINE", "LANCZOS"
# but I don't think it is good idea to support them for now
SUPPORTED_OVERVIEW_METHODS = ("NEAREST", "MODE", "AVERAGE", "GAUSS")
SUPPORTED_WARP_RESAMPLE_ALGS = (
    "near",
    "bilinear",
    "cubic",
    "cubicspline",
    "lanczos",
    "average",
    "mode",
    "max",
    "min",
    "med",
    "q1",
    "q3",
    "sum",
)
SUPPORTED_TRANSLATE_RESAMPLE_ALGS = (
    "nearest",
    "bilinear",
    "cubic",
    "cubicspline",
    "lanczos",
    "average",
    "rms",
    "mode",
)
SUPPORTED_VRT_RESAMPLE_ALGS = (
    "nearest",
    "bilinear",
    "cubic",
    "cubicspline",
    "lanczos",
    "average",
    "mode",
)


def polyfill_resample_alg_for_gdal_vrt(resample_alg):
    """check and polyfill input resample_alg

    mainly to deal with the issue of `gdal.BuildVRT` has different names of `resample_alg`
    than the names supported by `gdal.Warp`.
    """
    if resample_alg in SUPPORTED_VRT_RESAMPLE_ALGS:
        return resample_alg
    elif resample_alg == "near":
        # polyfill for the inconsistency of gdal
        return "nearest"
    else:
        raise ValueError(f"Unknown resampling alg {resample_alg}")
